package juc_12_funtionnal;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;

public class Demo02 {

    public static void main(String[] args) {
        Worker worker = new Worker();

        worker.checkTasks(task -> {
            System.out.println(task);
        });
    }
}

class Worker {
    private List<String> tasks = new ArrayList<>();

    public Worker() {
        this.tasks.add("alex");
        this.tasks.add("lucy");
        this.tasks.add("tom");
    }

    public void checkTasks(Consumer<String> action) {
        Objects.requireNonNull(action);
        for (String task : this.tasks) {
            action.accept(task);
        }
    }
}
